package com.gongguizhijia.Util;

import com.gongguizhijia.Constant.Constants;
import com.gongguizhijia.pojo.SystemMapEcuId;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Chenglei
 * @date 2021/6/1 16:20
 */
public class DfUtil {

    //存储数据
   public static  Map<String,List> map = new HashMap<>();

   //加载数据
   static {
       try {
           map = ImportExcel.importExcel();
       } catch (FileNotFoundException e) {
           e.printStackTrace();
       }
   }


    /**
     * 输入 系统id 导出 Excel
     */
   public static void exportDfExcelByEcuConfigId(String ecuCode , String systemId){
       try {
           String communicationProtocol = ExportExcel.getCommunicationProtocol(map,ecuCode);
           ExportExcel.ExportDfExcel(map,ecuCode,systemId,communicationProtocol);
       } catch (Exception e) {
           e.printStackTrace();
       }
   }


    /**
     * 测试
     * @param args
     * @throws FileNotFoundException
     */
    public static void main(String[] args) throws Exception {

        List<SystemMapEcuId> systemMapEcuIdList = map.get(Constants.LIST_SYSTEM_ECU_ID);
        for (SystemMapEcuId systemMapEcuIdLists: systemMapEcuIdList) {
            DfUtil.exportDfExcelByEcuConfigId(systemMapEcuIdLists.getEcuId(),systemMapEcuIdLists.getSystemId());
        }
       // DfUtil.exportDfExcelByEcuConfigId("ZF_INTARDER","SYSTEM_x00124");


    }
}
